package finance

import grails.test.*

class ChiSquareServiceTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }
    
    protected void tearDown() {
        super.tearDown()
    }
    
    def chiSquareService
    
    void testChiSquare() {
        def expected = [2, 1]as double[]
        def observed = [2, 1]as long[]
        assertEquals 0, chiSquareService.chiSquare(expected, observed)
        
        expected = [2/3.0, 1/3.0]as double[]
        observed = [2, 1]as long[]
        assertEquals 0, chiSquareService.chiSquare(expected, observed), 0.001
    }
    
    void testCanBeRejected() {
        def expected = [2, 1]as double[]
        def observed = [2, 1]as long[]
        def rejections = chiSquareService.canBeRejected(expected, observed)
        
        assertFalse rejections[0]
    }
}
